"""
伪数据生成器
===========
v0.0.1 by Jack Lee
2023/07/04
该脚本用于生成若干行伪数据Excel，与实际
"""
import pandas as pd
import random
from constants import *

# 托寄物品名列表
item_names = [
    '电脑', '机器人', '主机', '笔记本', '音响', '平板', 'ipad', 'MacBook', 'iMac', '照相机',
    '摄像机', 'RedmiBook', '打印机', '导航', 'GPS', '新手机', '行车记录仪', '手表', '蓝牙耳机',
    '蓝牙音箱', '电子烟', '筋膜枪', '相机', 'ETC', '电子秤', '显示器', '联想ThinkPad', 'xbox'
]

# 大区列表
regions = ['大区1', '大区2', '大区9']

# 目的地列表
destinations = ['目的地1', '目的地2', '目的地3', '目的地4', '目的地5', '目的地6', '目的地7', '目的地8', '目的地9', '目的地10',
               '目的地11', '目的地12', '目的地13', '目的地14', '目的地15', '目的地16', '目的地17', '目的地18', '目的地19', '目的地20',
               '目的地21', '目的地22', '目的地23', '目的地24', '目的地25', '目的地26', '目的地27', '目的地28', '目的地29', '目的地30',
               '目的地31', '目的地32', '目的地33', '目的地34', '目的地35', '目的地36', '目的地37', '目的地38', '目的地39', '目的地40',
               '目的地41', '目的地42', '目的地43', '目的地44', '目的地45', '目的地46', '目的地47', '目的地48', '目的地49', '目的地50',
               '目的地51', '目的地52', '目的地53', '目的地54', '目的地55', '目的地56', '目的地57', '目的地58', '目的地59', '目的地60',
               '目的地61', '目的地62', '目的地63', '目的地64', '目的地65', '目的地66', '目的地67', '目的地68', '目的地69', '目的地70',
               '目的地71', '目的地72', '目的地73', '目的地74', '目的地75', '目的地76', '目的地77', '目的地78', '目的地79', '目的地80',
               '目的地81', '目的地82', '目的地83', '目的地84', '目的地85', '目的地86', '目的地87', '目的地88', '目的地89', '目的地90',
               '目的地91', '目的地92', '目的地93', '目的地94', '目的地95', '目的地96', '目的地97', '目的地98', '目的地99']

# 生成随机运单号
def generate_waybill_number():
    return str(random.randint(1, 9)) + str(random.randint(1, 9)).zfill(11)

# 生成随机实际重量
def generate_actual_weight():
    return random.randint(1, 130)

# 生成随机数据
data = []
for _ in range(1048579):
    date = pd.Timestamp.now().strftime('%Y-%m-%d')
    region = random.choice(regions)
    region_code = random.randint(1000, 9999)
    origin_code = random.randint(1000, 9999)
    destination_code = random.randint(1000, 9999)
    waybill_number = generate_waybill_number()
    item_name = random.choice(item_names)
    item_modified = random.choice(['是', '否'])
    payment_method = random.choice(['支付宝', '微信', '月结'])
    account_number = random.randint(100000, 999999)
    actual_weight = generate_actual_weight()
    billing_weight = random.uniform(actual_weight, actual_weight + 10)
    quantity = random.randint(1, 5)
    freight = random.uniform(10, 50)
    product_type = random.choice(['标准件', '特殊件'])
    label_category = random.choice(['A标', 'B标', 'C标'])
    label_source = random.choice(['来源1', '来源2', '来源3'])
    scanner_model = random.choice(['型号1', '型号2', '型号3'])
    waybill_type = random.choice(['类型1', '类型2', '类型3'])
    recipient = random.choice(['收件员1', '收件员2', '收件员3'])
    is_real_name = random.choice(['是', '否'])
    real_name_time = pd.Timestamp.now().strftime('%Y-%m-%d %H:%M:%S')
    is_real_name_valid = random.choice(['是', '否'])
    is_open_box_inspection = random.choice(['是', '否'])
    is_station_inspected = random.choice(['是', '否'])
    inspection_result = random.choice(['结果1', '结果2', '结果3'])
    station_inspector_id = random.randint(10000, 99999)
    station_inspection_time = pd.Timestamp.now().strftime('%Y-%m-%d %H:%M:%S')
    pouch_number_1 = random.randint(1, 10)
    cage_number_1 = random.randint(1, 10)
    transit_code_1 = random.randint(1000, 9999)
    is_transit_inspected_1 = random.choice(['是', '否'])
    transit_inspection_result_1 = random.choice(['结果1', '结果2', '结果3'])
    transit_inspector_id_1 = random.randint(10000, 99999)
    transit_inspection_time_1 = pd.Timestamp.now().strftime('%Y-%m-%d %H:%M:%S')
    pouch_number_2 = random.randint(1, 10)
    cage_number_2 = random.randint(1, 10)
    transit_code_2 = random.randint(1000, 9999)
    is_transit_inspected_2 = random.choice(['是', '否'])
    transit_inspection_result_2 = random.choice(['结果1', '结果2', '结果3'])
    transit_inspector_id_2 = random.randint(10000, 99999)
    transit_inspection_time_2 = pd.Timestamp.now().strftime('%Y-%m-%d %H:%M:%S')
    pouch_number_3 = random.randint(1, 10)
    cage_number_3 = random.randint(1, 10)
    destination_transit_code = random.randint(1000, 9999)
    is_destination_transit_inspected = random.choice(['是', '否'])
    destination_transit_inspection_result = random.choice(['结果1', '结果2', '结果3'])
    destination_transit_inspector_id = random.randint(10000, 99999)
    destination_transit_inspection_time = pd.Timestamp.now().strftime('%Y-%m-%d %H:%M:%S')
    pouch_number_4 = random.randint(1, 10)
    cage_number_4 = random.randint(1, 10)
    destination_code = random.randint(1000, 9999)
    is_destination_inspected = random.choice(['是', '否'])
    destination_inspection_result = random.choice(['结果1', '结果2', '结果3'])
    destination_inspector_id = random.randint(10000, 99999)
    destination_inspection_time = pd.Timestamp.now().strftime('%Y-%m-%d %H:%M:%S')
    pouch_number_5 = random.randint(1, 10)
    cage_number_5 = random.randint(1, 10)
    parcel_exception_status = random.choice(['异常状态1', '异常状态2', '异常状态3'])
    other_inspection_code = random.choice(['代码1', '代码2', '代码3'])
    other_inspection_result = random.choice(['结果1', '结果2', '结果3'])
    other_inspector_id = random.randint(10000, 99999)
    other_inspection_time = pd.Timestamp.now().strftime('%Y-%m-%d %H:%M:%S')
    is_photo_required = random.choice(['是', '否'])
    is_3c_photo = random.choice(['是', '否'])
    
    row = [
        date, region, region_code, origin_code, destination_code, waybill_number, item_name,
        item_modified, payment_method, account_number, actual_weight, billing_weight, quantity,
        freight, product_type, label_category, label_source, scanner_model, waybill_type,
        recipient, is_real_name, real_name_time, is_real_name_valid, is_open_box_inspection,
        is_station_inspected, inspection_result, station_inspector_id, station_inspection_time,
        pouch_number_1, cage_number_1, transit_code_1, is_transit_inspected_1,
        transit_inspection_result_1, transit_inspector_id_1, transit_inspection_time_1,
        pouch_number_2, cage_number_2, transit_code_2, is_transit_inspected_2,
        transit_inspection_result_2, transit_inspector_id_2, transit_inspection_time_2,
        pouch_number_3, cage_number_3, destination_transit_code, is_destination_transit_inspected,
        destination_transit_inspection_result, destination_transit_inspector_id,
        destination_transit_inspection_time, pouch_number_4, cage_number_4, destination_code,
        is_destination_inspected, destination_inspection_result, destination_inspector_id,
        destination_inspection_time, pouch_number_5, cage_number_5, parcel_exception_status,
        other_inspection_code, other_inspection_result, other_inspector_id, other_inspection_time,
        is_photo_required, is_3c_photo
    ]
    data.append(row)

# 创建DataFrame并保存为CSV文件
df = pd.DataFrame(data, columns=[
    '日期', '大区', '地区代码', '原寄地网点代码', '目的地代码', '运单号', '托寄物品名', '托寄物是否有修改', '付款方式', '月结帐号', '实际重量',
    '计费重量', '件数', '运费', '产品类型', '标识类别', '标识来源', '巴枪型号', '运单类型', '收件员', '是否实名认证',
    '实名时间', '实名是否真实', '是否开箱验视', '网点是否查验（90）', '查验结果', '网点查验人员工号', '查验时间', '包牌号1', '笼号1',
    '中转场1代码', '中转场1是否查验（90）', '中转场1查验结果', '中转场1查验人员工号', '中转场1查验时间', '包牌号2', '笼号2', '中转场2代码',
    '中转场2是否查验（90）', '中转场2查验结果', '中转场2查验人员工号', '中转场2查验时间', '包牌号3', '笼号3', '目的地中转场代码',
    '目的地中转场是否查验（90）', '目的地中转场查验结果', '目的地中转场查验人员工号', '目的地中转场查验时间', '包牌号4', '笼号4', '目的地网点代码',
    '目的地网点是否查验（90）', '目的地网点查验结果', '目的地网点查验人员工号', '目的地网点查验时间', '包牌号5', '笼号5', '快件异常状态',
    '其他查验代码', '其他查验结果', '其他查验人员工号', '其他查验时间', '是否是WI要求拍照', '是否3C拍照'
])
df.to_csv(os.path.join(SOURCER_DIR,'pseudo_data.csv'), index=False)
